package com.mzwf.cloud.service;


import com.mzwf.cloud.entity.User;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class FeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {
    private static final Logger LOGGER= LoggerFactory.getLogger(FeignClientFallbackFactory.class);

    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient(){
            @Override
            public User findById(Long id){
               LOGGER.info("fallback",throwable);
               User user=new User();
                user.setId(-1L);
                user.setUsername("默认用户");
                return user;         
            }
        } ;
    }
}
